var app = getApp(),
  that
Page({

  /**
   * 页面的初始数据
   */
  data: {
    array: ['大型车', '小型车'],
    index: 0,
    item: 0,
    flag: true,

    provinceArr: ["粤", "京", "津", "渝", "沪", "冀", "晋", "辽", "吉", "黑", "苏", "浙", "皖", "闽", "赣", "鲁", "豫", "鄂", "湘", "琼", "川", "贵", "云", "陕", "甘", "青", "蒙", "桂", "宁", "新", "藏", "使", "领", "警", "学", "港", "澳"],
    hiddenPro: false, // 省份键盘
    carnum: '晋',
    carCard: '',
    city:''
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    that = this;
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady(e) {},

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {},

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  },
  /**车型 */
  bindPickerChange(e) {
    console.log('picker发送选择改变，携带值为', e.detail.value)
    this.setData({
      index: e.detail.value
    })
  },
  /**车牌首字 */
  carCardShow: function() {
    console.log(123)
    this.setData({
      hiddenPro: false,
      flag: false
    })
  },
  stoppropagation: function() {
    console.log(123)
    this.setData({
      hiddenPro: true,
      flag: true
    })
  },
  proTap(e) { //点击省份
    console.log(e)
    let province = e.currentTarget.dataset.province;
    let carnum = this.data.carnum;
    if (this.data.flag == false) {
      this.setData({
        carnum: province,
        hiddenPro: true,
        flag: true
      })
    } else {
      this.setData({
        carnum: province,
        hiddenPro: false,
        flag: false
      })
    }
  },
  formSubmit: function(e) {
    console.log(e)
    app.getData({
      url: 'http://v.juhe.cn/wz/citys?key=fe3f2b284ccd23255ca51abcd101f45b',
      method: 'POST',
      ok: function(res) {
        console.log(res.data.result)
        that.setData({
          city: res.data.result
        })
        app.getData({
          url: 'http://v.juhe.cn/wz/query',
          method: 'POST',
          data: {
            city:that.data.city ,
            hphm: that.data.carnum + that.data.cph,
            hpzlL: that.data.index,
            engineno:e.detail.value.fdjh,
            classno:e.detail.value.car,
            key: 'fe3f2b284ccd23255ca51abcd101f45b'
          },
          ok: function (res) {
            console.log(res)
          }
        })
      }
    })



  },
  carCard: function(t) {
    console.log(t.detail.value)
    this.setData({
      cph: t.detail.value,
    })
  },
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  },
})